package homeWork;

import java.util.ArrayList;
import java.util.Random;

public class Tool {
    public void noReapet(ArrayList arr) {
        for (int i = 0; i < arr.size(); i++) {
            int num=0;
            for (int j = 0; j < arr.size(); j++) {
                if (arr.get(i)==arr.get(j)) {
                    num+=1;
                    if(num>1){
                        arr.remove(j);
                        num-=1;
                    }
                }
            }
        }
    }

    public ArrayList getArr() {
        ArrayList arr = new ArrayList();
        for (int i = 0; arr.size()<10;i++){
            arr.add(new Random().nextInt(20)+1);
            noReapet(arr);
        }
        System.out.println(arr.toString());
        return arr;
    }

    public void arrSort(ArrayList arr){
        for (int i = 0; i < arr.size(); i++){
            for (int j =0;j<arr.size();j++){
                if(((int)(arr.get(i)))<((int)(arr.get(j)))){
                    int num=((int)(arr.get(i)));
                    arr.set(i,((int)(arr.get(j))));
                    arr.set(j,num);
                }
            }
        }

        System.out.println(arr.toString());
    }
}
